Repository navigation
Update EXP IC routines for HDF5 output - #229
Conversation
…nd applied this to all of the native particle generators.
… enclosing cube test optional
There was a problem hiding this comment.
Pull request overview
Adds HDF5 output support to EXP initial-condition generators using the runtime particle schema.
Changes:
- Introduces a shared HDF5 particle writer with MPI gathering, compression, and precision options.
- Integrates HDF5 output across six IC generators.
- Centralizes 1D mass models and adds HDF5 smoke tests.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
utils/ICs/ZangICs.cc |
Adds HDF5 output options. |
utils/ICs/ParticleHDF5.H |
Implements the shared writer. |
utils/ICs/massmodel1d.H |
Removes the local model header. |
utils/ICs/initial2d.cc |
Adds gendisk2d HDF5 output. |
utils/ICs/initial.cc |
Adds gendisk HDF5 output. |
utils/ICs/gensph.cc |
Adds distributed HDF5 output. |
utils/ICs/genslab.cc |
Reworks slab generation and output. |
utils/ICs/cubeICs.cc |
Adds cube HDF5 output. |
utils/ICs/CMakeLists.txt |
Uses centralized mass models. |
tests/CMakeLists.txt |
Registers HDF5 smoke tests. |
tests/check_hdf5_particles.py |
Validates particle schemas. |
include/massmodel1d.H |
Centralizes and expands 1D models. |
exputil/massmodel1d.cc |
Implements centralized models. |
exputil/CMakeLists.txt |
Adds models to exputil. |
Suppressed comments (3)
exputil/massmodel1d.cc:375
setDF(..., nint)stores a requested quadrature size, butcompute_modelignores it and always uses 400 points. Use the member so the public tuning parameter has an effect.
exputil/massmodel1d.cc:4- This source still constructs
std::ifstreamat line 26 but no longer includes<fstream>. Compilation now depends on an unrelated transitive include fromSLGridMP2.H; include the defining standard header directly.
include/massmodel1d.H:706 - The default constructor leaves both
epsilonanddist_definedindeterminate, althoughdistfimmediately usesepsilonand callers inspectdist_defined. Initialize a deliberate regularization value and mark the completed model as defined, as the other constructors do.
H = 1.0;
Omega = std::sqrt(2.0*M_PI/H);
norm = std::sqrt(2/Omega)/(M_PI*2.0*H);
Jmax = 0.5*Omega*H*H;
ModelID = "Uniform";
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: The9Cat <25960766+The9Cat@users.noreply.github.com>
|
@copilot I addressed your review below in a series of recent commits. Please review again. |
I reviewed the updated PR. One remaining medium-severity issue needs correction before merge: the filter IDs for SZIP, SHUFFLE, and FLETCHER32 are mismatched with HDF5’s actual built-in IDs in |
|
@copilot You are correct and it's worse than you said. In the lastest commits, I switched to HDF5's own numbering, where 2 is shuffle, 3 is Fletcher32 and 4 is SZIP, set through the proper API. The slab test would switch to filter 2, and a new test would check filters 2 to 4. This implies that After the updates, Please review the updates. |
Reviewed the latest changes. The implementation’s HDF5 IDs and APIs now line up: 2 uses shuffle, 3 uses Fletcher32, and 4 uses SZIP; the new round-trip checks exercise these correctly when the filter is available. One remaining test portability issue: |
…not all filters, e.g. SZIP, are available
|
@copilot Good point. Without an SZIP encoder, the code falls back to GZIP with shuffle, but the filter 4 test doesn’t accept that. It passes on on my development machine because HDF5 has full SZIP. The new commit makes the following changes:
Please check the updated script. |
The SZIP fallback assertion is now handled correctly, including the no-GZIP fallback to shuffle-only for the filter-specific cases. One remaining portability gap: the test script still assumes default GZIP in |
… successfully tested the script one more time...
|
@copilot You are right in principle, but this a rare edge case I'd treat as very low priority. It only matters on an HDF5 built without zlib. That's very rare, since zlib is a standard HDF5 dependency and is on in every distro, conda and PyPI build that I checked. Since GZIP is standard, every default-output case uses that default (cube at line 96, sphere, zang, slab and the disks). Without GZIP, check_filter(1) falls back to shuffle-only, so all of those would fail together. Moreover, the gendisk basis-cache check would fail on such a build too. It requires gzip, and the cache uses a GZIP filter that can't be skipped, so without zlib the cache simply isn't written. Anyway, to address this rare case, I added a helper function in the latest commit that looks for the fallback warning in a run's log. It returns GZIP level 5 with shuffle when there's no warning, and shuffle-only otherwise. The filter-4 check would use it too, so there's one rule in one place. Please check the latest commit to make sure I didn't miss something. |
I checked the latest helper in commit |
Summary
gensph,gendisk,gendisk2d,zangics,cubeics,slabicswith an-5,--hdf5option for producing HDF5This PR completes the deprecation of default ascii i/o for phase space, although ascii remains available if requested explicitly (e.g.
OutAsciiand automatic fallback to ascii phase-space input if HDF5 is not detected).Why
cephby more than an order of magnitude in write time.Tests
CTesttests to verify that the HDF5 files have the expected metadata and have particles masses that sum to some user-specificed expected value. Default is 1.gensph,slabicsandcubeics.slabicsIC generationslabicsgenerated ICsgendiskIC generationgendiskgenerated ICsTBD
EmpCylSL::H5compress=5. Was set to0during testing.